﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using ShadowCommando.Game;
using ShadowCommando.Game.Elements;
namespace ShadowCommando.Game.GameBoard
{
    class Field : IComparable
    {
        public Field(Point _fakePoint, Point _boardPoint, bool _obstacle)
        {
            fakePoint = _fakePoint;
            boardPoint = _boardPoint;
            h = g = 0;
            elementId = ElementId.None;
            obstacle = _obstacle;
        }
        public Field(int _fakeX, int _fakeY, int _boardX, int _boardY, bool _movable)
        {
            fakePoint = new Point(_fakeX, _fakeY);
            boardPoint = new Point(_boardX, _boardY);
            h = g = 0;
            elementId = ElementId.None;

        }

        #region Elements

        private ElementId elementId;
        private bool obstacle;
        private int h;
        private int g;

        private Field parent;

        Point fakePoint;
        Point boardPoint;

        #endregion
        #region Properties
        public ElementId ElementId
        {
            get
            {
                return elementId;
            }
            set
            {
                elementId = value;
            }
        }
        public bool Obstacle
        {
            get { return obstacle; }
            set { obstacle = value; }
        }
        public int H
        {
            get
            {
                return h;
            }
            set
            {
                h = value;
            }
        }
        public int G
        {
            get
            {
                return g;
            }
            set
            {
                g = value;
            }
        }
        public int F
        {
            get
            {
                return g + h;
            }
        }
        public Field Parent
        {
            get
            {
                return parent;
            }
            set
            {
                parent = value;
            }
        }
        public Point FakePoint
        {
            get
            {
                return fakePoint;
            }
            set
            {
                fakePoint = value;
            }
        }
        public Point BoardPoint
        {
            get
            {
                return boardPoint;
            }
            set
            {
                boardPoint = value;
            }
        }
        public int FakeX
        {
            get
            {
                return fakePoint.X;
            }
            set
            {
                fakePoint.X = value;
            }
        }
        public int FakeY
        {
            get
            {
                return fakePoint.Y;
            }
            set
            {
                fakePoint.Y = value;
            }
        }
        public int BoardX
        {
            get
            {
                return boardPoint.X;
            }
            set
            {
                boardPoint.X = value;
            }
        }
        public int BoardY
        {
            get
            {
                return boardPoint.Y;
            }
            set
            {
                boardPoint.Y = value;
            }
        }

        #endregion
        #region Functions
        public int CompareTo(object obj)
        {
            Field f = obj as Field;
            if (f != null)
            {
                if (F > f.F)
                    return 1;
                else if (F < f.F)
                    return -1;
                else
                    return 0;
            }
            else
                throw new Exception("Zle rzutowanie");
        }

        #endregion


    }
}
